<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="/static/css/cart.css">
  <link rel="stylesheet" href="/static/css/base.css">
</head>

<body>

  <div class="header">
    购物车

    <p>
      <span class="on active"><a href="/pages/index">返回首页</a> <a href="/pages/list">返回商品列表</a></span>
    </p>
  </div>

  <div class="content cart">
    <!-- JS 渲染 -->
  </div>
  <div class="footer">网页底部</div>





  <script id="cart_template" type="text/html">
    <% if (!list.length) { %>
    <!-- 空购物车 -->
    <div class="empty">
      <img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.huabanimg.com%2Fa4064bdab5f6c800ed664014f3eb7d13a4dd25b3138d0-hYHe07_fw658&refer=http%3A%2F%2Fhbimg.huabanimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654169688&t=9168caa529326a421bd570cbfc245de5" alt="">
    </div>
    <% } else { %>
    <!-- 有内容的购物车 -->
    <div class="full">
      <div class="top">
        <input class="select_all" type="checkbox" <%= selected === list.length ? 'checked' : '' %>> 全选
      </div>
      <ul>
        <% for (var i = 0; i < list.length; i++) { %>
        <li>
          <div class="select">
            <input class="select_item" data-id="<%= list[i].goods_id %>"  type="checkbox" <%= list[i].is_select ? 'checked' : '' %>>
          </div>
          <div class="show">
            <img src="<%= list[i].img_small_logo %>" alt="">
          </div>
          <div class="title">
            <%= list[i].title %>
          </div>
          <div class="price">
            ￥ <span><%= list[i].current_price %></span>
          </div>
          <div class="number">
            <button data-id="<%= list[i].goods_id %>" class="item_sub">-</button>
            <input type="text" value="<%= list[i].cart_number %>">
            <button data-id="<%= list[i].goods_id %>" class="item_add">+</button>
          </div>
          <div class="sub">
            ￥ <span><%= (list[i].current_price * list[i].cart_number).toFixed(2) %></span>
          </div>
          <div class="destory">
            <button data-id="<%= list[i].goods_id %>" class="item_del">删除</button>
          </div>
        </li>
        <% } %>

      </ul>
      <div class="bottom">
        <p>总件数 : <%= selectNum %></p>
        <div class="btns">
          <button class="pay" <%= selected === 0 ? 'disabled' : '' %>>去支付</button>
          <button class="clear_completed" <%= selected === 0 ? 'disabled' : '' %>>删除所有已选中</button>
          <button class="clear">清空购物车</button>
        </div>
        <p>总价格 : ￥ <span><%= selectPrice.toFixed(2) %></span></p>
      </div>
    </div>
    <% } %>
  </script>



  <script src="/static/vander/jquery/jquery.min.js"></script>
  <script src="/static/vander/template/template-web.js"></script>
  <script src="/static/js/cart.js"></script>
</body>

</html>